package controller

import (
	"gin-server/model"
	"github.com/gin-gonic/gin"
	"net/http"
	// "fmt"
)

func LoginJSON(c *gin.Context) {
	json := model.Login{}

	if c.BindJSON(&json) == nil {
		if json.Name == "root" && json.Password == "root" {
			c.JSON(http.StatusOK, gin.H{"status": "登录成功"})
		} else {
			c.JSON(http.StatusUnauthorized, gin.H{"status": "账号或密码错误"})
		}
	}
}

func LoginFORM(c *gin.Context) {
	form := model.Login{}

	if c.Bind(&form) == nil {
		if form.Name == "root" && form.Password == "root" {
			c.JSON(http.StatusOK, gin.H{"status": "登录成功"})
		} else {
			c.JSON(http.StatusUnauthorized, gin.H{"status": "账号或密码错误"})
		}
	}
}
